<template>
  <el-container class="container">
    <el-header class="header">
      <div class="title fl" @click="goHome">
        <!-- <img src="../assets/images/logo.png"> -->
        <span class="title-text">KVM管理系统</span>
      </div>
      <!-- <div class="exit fr" @click="exitLogin()">
        <img src="../assets/images/exit.png" alt />
        <span>Exit</span>
      </div> -->
      <el-dropdown class="info fr" trigger="hover" @command="handleCommand">
        <span class="el-dropdown-link">
          <i class="el-icon-setting"></i>
        </span>

        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="log">日志管理</el-dropdown-item>
          <el-dropdown-item command="dhcp">DHCP配置</el-dropdown-item>
          <el-dropdown-item command="password">修改密码</el-dropdown-item>
          <el-dropdown-item command="exit">退出登陆</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    <el-main class="main">
      <div class="main-box">
        <router-view></router-view>
      </div>
    </el-main>
    <EditPasswordDialog ref="EditPasswordDialog"></EditPasswordDialog>
    <EditDhcpDialog ref="EditDhcpDialog"></EditDhcpDialog>
  </el-container>
</template>

<script>
import EditPasswordDialog from "./EditPasswordDialog.vue";
import EditDhcpDialog from "./EditDhcpDialog.vue";
export default {
  name: "mainPage",
  components: { EditPasswordDialog, EditDhcpDialog},
  data() {
    return {
      name: "",
      is_admin: false,
      activePage: "assetManager",
      title: {
        group: "资产管理",
        item: "资产列表",
      },
    };
  },
  created() {},
  methods: {
    handleCommand(command) {
      if (command == "password") {
        this.$refs.EditPasswordDialog.open();
      } else if (command == "log") {
        this.$router.push({
          name: "log",
        });
      } else if (command == "dhcp") {
        this.$refs.EditDhcpDialog.open();
      } else if (command == "exit") {
        this.$fetch("/user/logout").then((res) => {
          if (res.error == 0) {
            this.$router.push({
              name: "login",
            });
          }
        });
      }
    },
    goHome() {
      this.$router.push({
        name: "machine",
      });
    },
  },
  mounted() {},
  watch: {},
};
</script>

<style scoped lang='scss'>
.container {
  width: 100%;
  height: 100vh;
  .header {
    // background-color: #B3C0D1;
    box-sizing: border-box;
    background: #34495e;
    color: #888;
    height: 60px;
    width: 100;
    margin: 2px 0px;
    box-shadow: 1px 1px 6px #ccc;
    line-height: 60px;
    position: relative;
    // border-radius: 5px;
    .title {
      cursor: pointer;
      height: 100%;
      .title-text {
        font-size: 24px;
        font-weight: bold;
        color: #fff;
        line-height: 60px;
      }
    }

    .info {
      width: 30px;
      height: 100%;
      float: right;
      cursor: pointer;
      .el-dropdown-link {
        width: 100%;
        height: 100%;
        display: flex;
        color: #fff;
        align-items: center;
        i {
          font-size: 24px;
        }
      }
    }
  }
  .main {
    width: 100%;
    // min-height: 800px;
    background-color: #e9eef3;
    color: #333;
    box-sizing: border-box;
    padding: 5px 10px;
    position: relative;
    .main-box {
      // border: 1px solid #d9d9d9;
      // box-shadow: 1px 1px 6px #ccc;
      width: 100%;
      height: 100%;
      background: white;
    }
  }
}
</style>
